/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JDialogUserConfig.java
 *
 * Created on 2009-11-30, 10:49:58
 */

/**
 *
 * @author Administrator
 */

package ClientDemo;

import com.sun.jna.NativeLong;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;
import java.awt.Component;
import java.awt.Rectangle;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.DefaultListModel;
import javax.swing.JCheckBox;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.ListCellRenderer;

/*****************************************************************************
 *类 ：    JDialogUserConfig
 *类描述 ：用户参数配置
 ****************************************************************************/
public class JDialogUserConfig extends javax.swing.JDialog {

      static HCNetSDK hCNetSDK = HCNetSDK.INSTANCE;
      private NativeLong m_lUserID;// 用户ID
      private HCNetSDK.NET_DVR_DEVICEINFO_V30 m_strDeviceInfo;//设备信息
      private HCNetSDK.NET_DVR_IPPARACFG  m_strIpparaCfg;//IP参数
      private HCNetSDK.NET_DVR_USER_V30 m_struUserCfg;//用户参数
      private CheckListItem m_LocalChannel[] = new CheckListItem[HCNetSDK.MAX_CHANNUM_V30];//本地list里对应Checkbox的值
      private CheckListItem m_RemoteChannel[] = new CheckListItem[HCNetSDK.MAX_CHANNUM_V30];//远程list里对应Checkbox的值   
      private int m_iUserIndex;//用户数组下标
      private boolean bInitialed;//Dialog是否已初始化

    /*************************************************
    函数:      JDialogUserConfig
    函数描述:	构造函数   Creates new form JDialogUserConfig
     *************************************************/
    public JDialogUserConfig(java.awt.Frame parent, boolean modal, NativeLong lUserID, HCNetSDK.NET_DVR_DEVICEINFO_V30 strDeviceInfo, HCNetSDK.NET_DVR_IPPARACFG  strIpparaCfg) {
        super(parent, modal);
        initComponents();
        
        m_strDeviceInfo = strDeviceInfo;
        m_strIpparaCfg = strIpparaCfg;
        m_lUserID = lUserID;

        //初始化对话框
        initialDialog();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jComboBoxPriority = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jComboBoxUser = new javax.swing.JComboBox();
        jLabel5 = new javax.swing.JLabel();
        jTextFieldUserIP = new javax.swing.JTextField();
        jTextFieldUserName = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jPasswordFieldPassConfirm = new javax.swing.JPasswordField();
        jPasswordFieldPassword = new javax.swing.JPasswordField();
        jLabel7 = new javax.swing.JLabel();
        jTextFieldMac1 = new javax.swing.JTextField();
        jTextFieldMac2 = new javax.swing.JTextField();
        jTextFieldMac3 = new javax.swing.JTextField();
        jTextFieldMac4 = new javax.swing.JTextField();
        jTextFieldMac5 = new javax.swing.JTextField();
        jTextFieldMac6 = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jPanelLocal = new javax.swing.JPanel();
        jCheckBoxLocalPlayback = new javax.swing.JCheckBox();
        jCheckBoxLoacalRecord = new javax.swing.JCheckBox();
        jCheckBoxLocalPTZ = new javax.swing.JCheckBox();
        jCheckBoxLocalBackup = new javax.swing.JCheckBox();
        jCheckBoxLocalState = new javax.swing.JCheckBox();
        jCheckBoxLocalUpdate = new javax.swing.JCheckBox();
        jCheckBoxLocalSetPara = new javax.swing.JCheckBox();
        jCheckBoxLocalIPCamera = new javax.swing.JCheckBox();
        jCheckBoxLocalReboot = new javax.swing.JCheckBox();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel8 = new javax.swing.JLabel();
        jComboBoxLocal = new javax.swing.JComboBox();
        jScrollPane1 = new javax.swing.JScrollPane();
        jListLocal = new javax.swing.JList();
        jButtonSaveLocal = new javax.swing.JButton();
        jPanelRemote = new javax.swing.JPanel();
        jCheckBoxRemotePlayback = new javax.swing.JCheckBox();
        jCheckBoxRemoteRealplay = new javax.swing.JCheckBox();
        jCheckBoxRemoteRecord = new javax.swing.JCheckBox();
        jCheckBoxRemotePTZ = new javax.swing.JCheckBox();
        jCheckBoxRemoteState = new javax.swing.JCheckBox();
        jCheckBoxRemoteUpdate = new javax.swing.JCheckBox();
        jCheckBoxRemoteSerial = new javax.swing.JCheckBox();
        jCheckBoxRemoteAlarm = new javax.swing.JCheckBox();
        jCheckBoxRemoteSetPara = new javax.swing.JCheckBox();
        jCheckBoxRemoteVoice = new javax.swing.JCheckBox();
        jCheckBoxRemoteControl = new javax.swing.JCheckBox();
        jCheckBoxRemoteIPCamera = new javax.swing.JCheckBox();
        jCheckBoxRemoteReboot = new javax.swing.JCheckBox();
        jSeparator2 = new javax.swing.JSeparator();
        jScrollPane2 = new javax.swing.JScrollPane();
        jListRemote = new javax.swing.JList();
        jLabel14 = new javax.swing.JLabel();
        jComboBoxRemote = new javax.swing.JComboBox();
        jButtonSaveRemote = new javax.swing.JButton();
        jButtonSaveUser = new javax.swing.JButton();
        jButtonSetup = new javax.swing.JButton();
        jButtonExit = new javax.swing.JButton();
        jButtonUPdate = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("用户配置");

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
        jPanel1.setForeground(new java.awt.Color(0, 70, 213));
        jPanel1.setLayout(null);

        jLabel1.setText("用户");
        jPanel1.add(jLabel1);
        jLabel1.setBounds(20, 20, 24, 15);

        jLabel2.setText("优先级");
        jPanel1.add(jLabel2);
        jLabel2.setBounds(20, 50, 36, 15);

        jComboBoxPriority.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "普通用户", "操作员", "管理员" }));
        jPanel1.add(jComboBoxPriority);
        jComboBoxPriority.setBounds(80, 50, 80, 20);

        jLabel3.setText("用户名称");
        jPanel1.add(jLabel3);
        jLabel3.setBounds(180, 20, 50, 15);

        jLabel4.setText("允许IP");
        jPanel1.add(jLabel4);
        jLabel4.setBounds(180, 50, 36, 15);

        jComboBoxUser.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "超级用户", "用户1", "用户2", "用户3", "用户4", "用户5", "用户6", "用户7", "用户8", "用户9", "用户10", "用户11", "用户12", "用户13", "用户14", "用户15", "用户16", "用户17", "用户18", "用户19", "用户20", "用户21", "用户22", "用户23", "用户24", "用户25", "用户26", "用户27", "用户28", "用户29", "用户30", "用户31" }));
        jComboBoxUser.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxUserActionPerformed(evt);
            }
        });
        jPanel1.add(jComboBoxUser);
        jComboBoxUser.setBounds(80, 20, 80, 20);

        jLabel5.setText("密码");
        jPanel1.add(jLabel5);
        jLabel5.setBounds(340, 20, 24, 15);
        jPanel1.add(jTextFieldUserIP);
        jTextFieldUserIP.setBounds(240, 50, 80, 21);
        jPanel1.add(jTextFieldUserName);
        jTextFieldUserName.setBounds(240, 20, 80, 21);

        jLabel6.setText("确认密码");
        jPanel1.add(jLabel6);
        jLabel6.setBounds(450, 20, 50, 15);
        jPanel1.add(jPasswordFieldPassConfirm);
        jPasswordFieldPassConfirm.setBounds(510, 20, 80, 21);
        jPanel1.add(jPasswordFieldPassword);
        jPasswordFieldPassword.setBounds(370, 20, 70, 21);

        jLabel7.setText("允许物理地址");
        jPanel1.add(jLabel7);
        jLabel7.setBounds(340, 50, 80, 15);
        jPanel1.add(jTextFieldMac1);
        jTextFieldMac1.setBounds(420, 50, 20, 21);
        jPanel1.add(jTextFieldMac2);
        jTextFieldMac2.setBounds(450, 50, 20, 21);
        jPanel1.add(jTextFieldMac3);
        jTextFieldMac3.setBounds(480, 50, 20, 21);
        jPanel1.add(jTextFieldMac4);
        jTextFieldMac4.setBounds(510, 50, 20, 21);
        jPanel1.add(jTextFieldMac5);
        jTextFieldMac5.setBounds(540, 50, 20, 21);
        jPanel1.add(jTextFieldMac6);
        jTextFieldMac6.setBounds(570, 50, 20, 21);

        jLabel9.setText(":");
        jPanel1.add(jLabel9);
        jLabel9.setBounds(440, 50, 10, 15);

        jLabel10.setText(":");
        jPanel1.add(jLabel10);
        jLabel10.setBounds(470, 50, 10, 15);

        jLabel11.setText(":");
        jPanel1.add(jLabel11);
        jLabel11.setBounds(500, 50, 10, 15);

        jLabel12.setText(":");
        jPanel1.add(jLabel12);
        jLabel12.setBounds(530, 50, 10, 15);

        jLabel13.setText(":");
        jPanel1.add(jLabel13);
        jLabel13.setBounds(560, 50, 10, 15);

        jPanelLocal.setBorder(javax.swing.BorderFactory.createTitledBorder("设备本地权限"));

        jCheckBoxLocalPlayback.setText("本地回放");

        jCheckBoxLoacalRecord.setText("本地录像");

        jCheckBoxLocalPTZ.setText("本地云台控制");

        jCheckBoxLocalBackup.setText("本地备份");

        jCheckBoxLocalState.setText("本地查看状态,日志");

        jCheckBoxLocalUpdate.setText("升级,格式化");

        jCheckBoxLocalSetPara.setText("本地设置参数");

        jCheckBoxLocalIPCamera.setText("本地IP接入配置");

        jCheckBoxLocalReboot.setText("本地重启,关机");

        jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);

        jLabel8.setText("权限类型");

        jComboBoxLocal.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "本地回放", "本地录像", "云台控制", "本地备份" }));
        jComboBoxLocal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxLocalActionPerformed(evt);
            }
        });

        jScrollPane1.setViewportView(jListLocal);

        jButtonSaveLocal.setText("保存");
        jButtonSaveLocal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSaveLocalActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelLocalLayout = new javax.swing.GroupLayout(jPanelLocal);
        jPanelLocal.setLayout(jPanelLocalLayout);
        jPanelLocalLayout.setHorizontalGroup(
            jPanelLocalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelLocalLayout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addGroup(jPanelLocalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jCheckBoxLocalState)
                    .addComponent(jCheckBoxLocalBackup)
                    .addComponent(jCheckBoxLocalPTZ)
                    .addComponent(jCheckBoxLocalPlayback)
                    .addComponent(jCheckBoxLoacalRecord))
                .addGap(12, 12, 12)
                .addGroup(jPanelLocalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jCheckBoxLocalReboot)
                    .addComponent(jCheckBoxLocalSetPara)
                    .addComponent(jCheckBoxLocalUpdate)
                    .addComponent(jCheckBoxLocalIPCamera))
                .addGap(20, 20, 20)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(29, 29, 29)
                .addGroup(jPanelLocalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelLocalLayout.createSequentialGroup()
                        .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jComboBoxLocal, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanelLocalLayout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jButtonSaveLocal, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanelLocalLayout.setVerticalGroup(
            jPanelLocalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelLocalLayout.createSequentialGroup()
                .addGroup(jPanelLocalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanelLocalLayout.createSequentialGroup()
                        .addComponent(jCheckBoxLocalPlayback)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jCheckBoxLoacalRecord)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jCheckBoxLocalPTZ)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jCheckBoxLocalBackup)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jCheckBoxLocalState))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanelLocalLayout.createSequentialGroup()
                        .addGroup(jPanelLocalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel8)
                            .addComponent(jComboBoxLocal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 134, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanelLocalLayout.createSequentialGroup()
                        .addComponent(jCheckBoxLocalUpdate)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jCheckBoxLocalSetPara)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jCheckBoxLocalIPCamera)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jCheckBoxLocalReboot)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 42, Short.MAX_VALUE)
                        .addComponent(jButtonSaveLocal)))
                .addContainerGap())
        );

        jPanel1.add(jPanelLocal);
        jPanelLocal.setBounds(10, 80, 580, 200);

        jPanelRemote.setBorder(javax.swing.BorderFactory.createTitledBorder("客户端远程权限"));

        jCheckBoxRemotePlayback.setText("远程回放");

        jCheckBoxRemoteRealplay.setText("网络预览");

        jCheckBoxRemoteRecord.setText("远程手动录像");

        jCheckBoxRemotePTZ.setText("云台控制");

        jCheckBoxRemoteState.setText("查看状态,日志");

        jCheckBoxRemoteUpdate.setText("升级,格式化");

        jCheckBoxRemoteSerial.setText("远程控制串口");

        jCheckBoxRemoteAlarm.setText("报警上传,输出");

        jCheckBoxRemoteSetPara.setText("设置参数");

        jCheckBoxRemoteVoice.setText("语音对讲");

        jCheckBoxRemoteControl.setText("远程控制本地输出");

        jCheckBoxRemoteIPCamera.setText("远程IP接入配置");

        jCheckBoxRemoteReboot.setText("远程重启,关机");

        jSeparator2.setOrientation(javax.swing.SwingConstants.VERTICAL);

        jScrollPane2.setViewportView(jListRemote);

        jLabel14.setText("权限类型");

        jComboBoxRemote.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "远程回放", "远程预览", "远程手动录像", "远程云台控制" }));
        jComboBoxRemote.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxRemoteActionPerformed(evt);
            }
        });

        jButtonSaveRemote.setText("保存");
        jButtonSaveRemote.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSaveRemoteActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelRemoteLayout = new javax.swing.GroupLayout(jPanelRemote);
        jPanelRemote.setLayout(jPanelRemoteLayout);
        jPanelRemoteLayout.setHorizontalGroup(
            jPanelRemoteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelRemoteLayout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addGroup(jPanelRemoteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jCheckBoxRemotePlayback)
                    .addGroup(jPanelRemoteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(jPanelRemoteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jCheckBoxRemoteSerial)
                            .addComponent(jCheckBoxRemoteAlarm)
                            .addComponent(jCheckBoxRemoteUpdate))
                        .addGroup(jPanelRemoteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jCheckBoxRemotePTZ)
                            .addComponent(jCheckBoxRemoteState)
                            .addComponent(jCheckBoxRemoteRecord)
                            .addComponent(jCheckBoxRemoteRealplay))))
                .addGap(25, 25, 25)
                .addGroup(jPanelRemoteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jCheckBoxRemoteVoice)
                    .addComponent(jCheckBoxRemoteSetPara)
                    .addComponent(jCheckBoxRemoteControl)
                    .addComponent(jCheckBoxRemoteIPCamera)
                    .addComponent(jCheckBoxRemoteReboot))
                .addGap(18, 18, 18)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(17, 17, 17)
                .addGroup(jPanelRemoteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanelRemoteLayout.createSequentialGroup()
                        .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jComboBoxRemote, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jButtonSaveRemote, javax.swing.GroupLayout.DEFAULT_SIZE, 73, Short.MAX_VALUE)
                .addGap(10, 10, 10))
        );
        jPanelRemoteLayout.setVerticalGroup(
            jPanelRemoteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelRemoteLayout.createSequentialGroup()
                .addComponent(jCheckBoxRemotePlayback)
                .addGap(2, 2, 2)
                .addComponent(jCheckBoxRemoteRealplay)
                .addGap(2, 2, 2)
                .addComponent(jCheckBoxRemoteRecord)
                .addGap(2, 2, 2)
                .addComponent(jCheckBoxRemotePTZ)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jCheckBoxRemoteState)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jCheckBoxRemoteUpdate)
                .addGap(2, 2, 2)
                .addComponent(jCheckBoxRemoteSerial)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jCheckBoxRemoteAlarm))
            .addGroup(jPanelRemoteLayout.createSequentialGroup()
                .addGroup(jPanelRemoteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboBoxRemote, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel14))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 174, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelRemoteLayout.createSequentialGroup()
                .addComponent(jCheckBoxRemoteSetPara)
                .addGap(2, 2, 2)
                .addComponent(jCheckBoxRemoteVoice)
                .addGap(2, 2, 2)
                .addComponent(jCheckBoxRemoteControl)
                .addGap(2, 2, 2)
                .addComponent(jCheckBoxRemoteIPCamera)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jCheckBoxRemoteReboot)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 57, Short.MAX_VALUE)
                .addComponent(jButtonSaveRemote))
            .addComponent(jSeparator2, javax.swing.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE)
        );

        jPanel1.add(jPanelRemote);
        jPanelRemote.setBounds(10, 280, 580, 230);

        jButtonSaveUser.setText("保存");
        jButtonSaveUser.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSaveUserActionPerformed(evt);
            }
        });
        jPanel1.add(jButtonSaveUser);
        jButtonSaveUser.setBounds(20, 520, 81, 23);

        jButtonSetup.setText("设置");
        jButtonSetup.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSetupActionPerformed(evt);
            }
        });

        jButtonExit.setText("退出");
        jButtonExit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonExitActionPerformed(evt);
            }
        });

        jButtonUPdate.setText("刷新");
        jButtonUPdate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonUPdateActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 604, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(33, 33, 33)
                .addComponent(jButtonSetup, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(44, 44, 44)
                .addComponent(jButtonUPdate, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 281, Short.MAX_VALUE)
                .addComponent(jButtonExit, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(54, 54, 54))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 555, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 12, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonSetup)
                    .addComponent(jButtonExit)
                    .addComponent(jButtonUPdate))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

     /*************************************************
     函数:      "退出" 按钮单击响应函数
     函数描述:	销毁对话框
      *************************************************/
    private void jButtonExitActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonExitActionPerformed
    {//GEN-HEADEREND:event_jButtonExitActionPerformed
       dispose();
    }//GEN-LAST:event_jButtonExitActionPerformed

     /*************************************************
     函数:      "用户" 组合框选项改变响应函数
     函数描述:	显示所选用户的参数
      *************************************************/
    private void jComboBoxUserActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jComboBoxUserActionPerformed
    {//GEN-HEADEREND:event_jComboBoxUserActionPerformed
        if(bInitialed)
        {
            showSingleUser();
        }
    }//GEN-LAST:event_jComboBoxUserActionPerformed

     /*************************************************
     函数:      本地 "权限类型" 组合框选项改变响应函数
     函数描述:	显示对应的权限参数
      *************************************************/
    private void jComboBoxLocalActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jComboBoxLocalActionPerformed
    {//GEN-HEADEREND:event_jComboBoxLocalActionPerformed
        if(bInitialed)
        {
            showLocalChannel();
        }
    }//GEN-LAST:event_jComboBoxLocalActionPerformed

     /*************************************************
     函数:      远程 "权限类型" 组合框选项改变响应函数
     函数描述:	显示对应的权限参数
      *************************************************/
    private void jComboBoxRemoteActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jComboBoxRemoteActionPerformed
    {//GEN-HEADEREND:event_jComboBoxRemoteActionPerformed
      if(bInitialed)
      {
          showRemoteChannel();
      }
    }//GEN-LAST:event_jComboBoxRemoteActionPerformed

     /*************************************************
     函数:      本地权限类型  "保存"按钮单击响应函数
     函数描述:   保存权限类型对应通道参数
      *************************************************/
    private void jButtonSaveLocalActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonSaveLocalActionPerformed
    {//GEN-HEADEREND:event_jButtonSaveLocalActionPerformed
        m_iUserIndex = jComboBoxUser.getSelectedIndex();
        int iRightType = jComboBoxLocal.getSelectedIndex();
        switch (iRightType)
        {
            case 0://本地回放
                for (int i = 0; i < HCNetSDK.MAX_CHANNUM_V30; i++)
                {
                    m_struUserCfg.struUser[m_iUserIndex].byLocalPlaybackRight[i] = (byte) (m_LocalChannel[i].getCheck() ? 1 : 0);
                }
                break;
            case 1://本地录像
                for (int i = 0; i < HCNetSDK.MAX_CHANNUM_V30; i++)
                {
                    m_struUserCfg.struUser[m_iUserIndex].byLocalRecordRight[i] = (byte) (m_LocalChannel[i].getCheck() ? 1 : 0);
                }
                break;
            case 2://云台控制
                for (int i = 0; i < HCNetSDK.MAX_CHANNUM_V30; i++)
                {
                    m_struUserCfg.struUser[m_iUserIndex].byLocalPTZRight[i] = (byte) (m_LocalChannel[i].getCheck() ? 1 : 0);
                }
                break;
            case 3://本地备份
                for (int i = 0; i < HCNetSDK.MAX_CHANNUM_V30; i++)
                {
                    m_struUserCfg.struUser[m_iUserIndex].byLocalBackupRight[i] = (byte) (m_LocalChannel[i].getCheck() ? 1 : 0);
                }
                break;
        }
    }//GEN-LAST:event_jButtonSaveLocalActionPerformed

     /*************************************************
     函数:      远程权限类型  "保存"按钮单击响应函数
     函数描述:   保存权限类型对应通道参数
      *************************************************/
    private void jButtonSaveRemoteActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonSaveRemoteActionPerformed
    {//GEN-HEADEREND:event_jButtonSaveRemoteActionPerformed
        m_iUserIndex = jComboBoxUser.getSelectedIndex();
        int iRightType = jComboBoxRemote.getSelectedIndex();
        switch (iRightType)
        {
            case 0://本地回放
                for (int i = 0; i < HCNetSDK.MAX_CHANNUM_V30; i++)
                {
                    m_struUserCfg.struUser[m_iUserIndex].byNetPlaybackRight[i] = (byte) (m_RemoteChannel[i].getCheck() ? 1 : 0);
                }
                break;
            case 1://本地录像
                for (int i = 0; i < HCNetSDK.MAX_CHANNUM_V30; i++)
                {
                    m_struUserCfg.struUser[m_iUserIndex].byNetPreviewRight[i] = (byte) (m_RemoteChannel[i].getCheck() ? 1 : 0);
                }
                break;
            case 2://云台控制
                for (int i = 0; i < HCNetSDK.MAX_CHANNUM_V30; i++)
                {
                    m_struUserCfg.struUser[m_iUserIndex].byNetRecordRight[i] = (byte) (m_RemoteChannel[i].getCheck() ? 1 : 0);
                }
                break;
            case 3://本地备份
                for (int i = 0; i < HCNetSDK.MAX_CHANNUM_V30; i++)
                {
                    m_struUserCfg.struUser[m_iUserIndex].byNetPTZRight[i] = (byte) (m_RemoteChannel[i].getCheck() ? 1 : 0);
                }
                break;
        }
    }//GEN-LAST:event_jButtonSaveRemoteActionPerformed

     /*************************************************
     函数:      全局 "保存" 按钮单击响应函数
     函数描述:	保存用户名 密码 优先级  IP  Mac地址 权限等参数至结构体
      *************************************************/
    private void jButtonSaveUserActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonSaveUserActionPerformed
    {//GEN-HEADEREND:event_jButtonSaveUserActionPerformed
         m_iUserIndex = jComboBoxUser.getSelectedIndex();

        //用户名
         m_struUserCfg.struUser[m_iUserIndex].sUserName = new String(jTextFieldUserName.getText() + "\0").getBytes();

        //密码
         if(new String(jPasswordFieldPassword.getPassword()).equals(new String(jPasswordFieldPassConfirm.getPassword())))
         {
             m_struUserCfg.struUser[m_iUserIndex].sPassword = new String(jPasswordFieldPassword.getPassword() + "\0").getBytes();
         }
         else
         {
             JOptionPane.showMessageDialog(this, "密码与确认密码不一致");
             System.out.println(jPasswordFieldPassword.getPassword());
                          System.out.println(jPasswordFieldPassConfirm.getPassword());
             return;
         }

        //优先级
        m_struUserCfg.struUser[m_iUserIndex].byPriority = (byte)jComboBoxPriority.getSelectedIndex();

        //允许IP
        m_struUserCfg.struUser[m_iUserIndex].struUserIP.sIpV4 = new String(jTextFieldUserIP.getText() + "\0").getBytes();

        //允许mac地址
        m_struUserCfg.struUser[m_iUserIndex].byMACAddr[0] = (byte) Integer.parseInt(jTextFieldMac1.getText(), 16);
        m_struUserCfg.struUser[m_iUserIndex].byMACAddr[1] = (byte) Integer.parseInt(jTextFieldMac2.getText(), 16);
        m_struUserCfg.struUser[m_iUserIndex].byMACAddr[2] = (byte) Integer.parseInt(jTextFieldMac3.getText(), 16);
        m_struUserCfg.struUser[m_iUserIndex].byMACAddr[3] = (byte) Integer.parseInt(jTextFieldMac4.getText(), 16);
        m_struUserCfg.struUser[m_iUserIndex].byMACAddr[4] = (byte) Integer.parseInt(jTextFieldMac5.getText(), 16);
        m_struUserCfg.struUser[m_iUserIndex].byMACAddr[5] = (byte) Integer.parseInt(jTextFieldMac6.getText(), 16);

        //本地操作权限
        m_struUserCfg.struUser[m_iUserIndex].byLocalRight[0] = (byte) (jCheckBoxLocalPTZ.isSelected() ? 1 : 0);
        m_struUserCfg.struUser[m_iUserIndex].byLocalRight[1] = (byte) (jCheckBoxLoacalRecord.isSelected() ? 1 : 0);
        m_struUserCfg.struUser[m_iUserIndex].byLocalRight[2] = (byte) (jCheckBoxLocalPlayback.isSelected() ? 1 : 0);
        m_struUserCfg.struUser[m_iUserIndex].byLocalRight[3] = (byte) (jCheckBoxLocalSetPara.isSelected() ? 1 : 0);
        m_struUserCfg.struUser[m_iUserIndex].byLocalRight[4] = (byte) (jCheckBoxLocalState.isSelected() ? 1 : 0);
        m_struUserCfg.struUser[m_iUserIndex].byLocalRight[5] = (byte) (jCheckBoxLocalUpdate.isSelected() ? 1 : 0);
        m_struUserCfg.struUser[m_iUserIndex].byLocalRight[7] = (byte) (jCheckBoxLocalIPCamera.isSelected() ? 1 : 0);
        m_struUserCfg.struUser[m_iUserIndex].byLocalRight[8] = (byte) (jCheckBoxLocalBackup.isSelected() ? 1 : 0);
        m_struUserCfg.struUser[m_iUserIndex].byLocalRight[9] = (byte) (jCheckBoxLocalReboot.isSelected() ? 1 : 0);

        //远程操作权限
        m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[0] = (byte) (jCheckBoxRemotePTZ.isSelected() ? 1 : 0);
        m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[1] = (byte) (jCheckBoxRemoteRecord.isSelected() ? 1 : 0);
        m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[2] = (byte) (jCheckBoxRemotePlayback.isSelected() ? 1 : 0);
        m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[3] = (byte) (jCheckBoxRemoteSetPara.isSelected() ? 1 : 0);
        m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[4] = (byte) (jCheckBoxRemoteState.isSelected() ? 1 : 0);
        m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[5] = (byte) (jCheckBoxRemoteUpdate.isSelected() ? 1 : 0);
        m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[6] = (byte) (jCheckBoxRemoteVoice.isSelected() ? 1 : 0);
        m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[7] = (byte) (jCheckBoxRemoteRealplay.isSelected() ? 1 : 0);
        m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[8] = (byte) (jCheckBoxRemoteAlarm.isSelected() ? 1 : 0);
        m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[9] = (byte) (jCheckBoxRemoteControl.isSelected() ? 1 : 0);
        m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[10] = (byte) (jCheckBoxRemoteSerial.isSelected() ? 1 : 0);
        m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[12] = (byte) (jCheckBoxRemoteIPCamera.isSelected() ? 1 : 0);
        m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[13] = (byte) (jCheckBoxRemoteReboot.isSelected() ? 1 : 0);

    }//GEN-LAST:event_jButtonSaveUserActionPerformed

     /*************************************************
     函数:      "设置" 按钮单击响应函数
     函数描述:   调用接口设置参数至设备
      *************************************************/
    private void jButtonSetupActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonSetupActionPerformed
    {//GEN-HEADEREND:event_jButtonSetupActionPerformed
        m_struUserCfg.write();
        Pointer lpConfig = m_struUserCfg.getPointer();
        boolean setDVRConfigSuc = hCNetSDK.NET_DVR_SetDVRConfig(m_lUserID, HCNetSDK.NET_DVR_SET_USERCFG_V30,
                new NativeLong(0), lpConfig, m_struUserCfg.size());
        m_struUserCfg.read();
        if (setDVRConfigSuc != true)
        {
            JOptionPane.showMessageDialog(this, "设置用户参数失败");
            return;
        }
        else
        {
            JOptionPane.showMessageDialog(this, "设置用户参数成功");
        }
    }//GEN-LAST:event_jButtonSetupActionPerformed

    /*************************************************
     函数:      "刷新" 按钮单击响应函数
     函数描述:   重新从设备获取参数并显示
      *************************************************/
    private void jButtonUPdateActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonUPdateActionPerformed
    {//GEN-HEADEREND:event_jButtonUPdateActionPerformed
       m_struUserCfg = new HCNetSDK.NET_DVR_USER_V30();
       m_struUserCfg.write();
       Pointer lpPicConfig = m_struUserCfg.getPointer();
       boolean getDVRConfigSuc = hCNetSDK.NET_DVR_GetDVRConfig(m_lUserID, HCNetSDK.NET_DVR_GET_USERCFG_V30, new NativeLong(0), lpPicConfig, m_struUserCfg.size(), new IntByReference(0));
       m_struUserCfg.read();
       if (getDVRConfigSuc == false)
       {
           JOptionPane.showMessageDialog(this, "获取用户配置信息失败!");
           return;
       }
       //显示的第一个用户也就是超级用户
      jComboBoxUser.setSelectedIndex(0);
    }//GEN-LAST:event_jButtonUPdateActionPerformed

    /*************************************************
     函数:      initialDialog
     函数描述:   初始化对话框,获取参数,显示第一个用户的参数
      *************************************************/
   private void initialDialog()
   {
       //起始通道号
       int iStartChan = m_strDeviceInfo.byStartChan;
       //模拟通道数
       int iChannum = m_strDeviceInfo.byChanNum;

       //先将每个checkbox初始化,便于以后赋值,不显示的也初始化
       for(int i =0; i < HCNetSDK.MAX_CHANNUM_V30; i++)
       {
       m_LocalChannel[i] = new CheckListItem(false, " ");
       m_RemoteChannel[i] = new CheckListItem(false, " ");
       }

        //设备本地权限通道list初始化
        jListLocal.setCellRenderer(new CheckListItemRenderer());
        DefaultListModel listModelLocal = new DefaultListModel();
        jListLocal.setModel(listModelLocal);
        jListLocal.addMouseListener(new CheckListMouseListener());
        
        for (int i = 0; i < iChannum; i++)
        {
               m_LocalChannel[i] = new CheckListItem(false, "Camera" + (i + iStartChan));
               listModelLocal.addElement(m_LocalChannel[i]);
        }
        for (int i = 0; i < HCNetSDK.MAX_IP_CHANNEL; i++)
        {
            if (m_strIpparaCfg.struIPChanInfo[i].byEnable == 1)
            {
                 m_LocalChannel[i + 32] = new CheckListItem(false, "IPCamara" + (i + iStartChan));
                 listModelLocal.addElement(m_LocalChannel[i + 32]);
            }
        }
        
        //设备远程权限通道list初始化
        jListRemote.setCellRenderer(new CheckListItemRenderer());
        DefaultListModel listModelRemote = new DefaultListModel();
        jListRemote.setModel(listModelRemote);
        jListRemote.addMouseListener(new CheckListMouseListener());
        
        for (int i = 0; i < iChannum; i++)
        {
               m_RemoteChannel[i] = new CheckListItem(false, "Camera" + (i + iStartChan));
               listModelRemote.addElement(m_RemoteChannel[i]);
        }
        for (int i = 0; i < HCNetSDK.MAX_IP_CHANNEL; i++)
        {
            if (m_strIpparaCfg.struIPChanInfo[i].byEnable == 1)
            {
                 m_RemoteChannel[i + 32] = new CheckListItem(false, "IPCamara" + (i + iStartChan));
                 listModelRemote.addElement(m_RemoteChannel[i + 32]);
            }
        }

       m_struUserCfg = new HCNetSDK.NET_DVR_USER_V30();
       m_struUserCfg.write();
       Pointer lpPicConfig = m_struUserCfg.getPointer();
       boolean getDVRConfigSuc = hCNetSDK.NET_DVR_GetDVRConfig(m_lUserID, HCNetSDK.NET_DVR_GET_USERCFG_V30, new NativeLong(0), lpPicConfig, m_struUserCfg.size(), new IntByReference(0));
       m_struUserCfg.read();
       if (getDVRConfigSuc == false)
       {
           JOptionPane.showMessageDialog(this, "获取用户配置信息失败!");
           return;
       }
       //初始化时显示的第一个用户也就是超级用户
      jComboBoxUser.setSelectedIndex(0);
      showSingleUser();

      bInitialed = true;
   }

    /*************************************************
     函数:      showSingleUser
     函数描述:   显示单个用户的参数
      *************************************************/
    private void showSingleUser()
    {
        m_iUserIndex = jComboBoxUser.getSelectedIndex();

        String[] s = new String[2];
        //用户名
        s = new String(m_struUserCfg.struUser[m_iUserIndex].sUserName).split("\0", 2);
        jTextFieldUserName.setText(s[0]);
        //密码
        s = new String(m_struUserCfg.struUser[m_iUserIndex].sPassword).split("\0", 2);
        jPasswordFieldPassword.setText(s[0]);
        //确认密码
        jPasswordFieldPassConfirm.setText(s[0]);
        //优先级
        if(m_iUserIndex == 0)
        {
           jComboBoxPriority.setSelectedIndex(2); 
        }
        else
        {
        jComboBoxPriority.setSelectedIndex(m_struUserCfg.struUser[m_iUserIndex].byPriority);
        }
        //允许IP
         s = new String(m_struUserCfg.struUser[m_iUserIndex].struUserIP.sIpV4).split("\0", 2);
        jTextFieldUserIP.setText(s[0]);
        //允许mac地址
        jTextFieldMac1.setText(String.format("%02x", m_struUserCfg.struUser[m_iUserIndex].byMACAddr[0]));
        jTextFieldMac2.setText(String.format("%02x", m_struUserCfg.struUser[m_iUserIndex].byMACAddr[1]));
        jTextFieldMac3.setText(String.format("%02x", m_struUserCfg.struUser[m_iUserIndex].byMACAddr[2]));
        jTextFieldMac4.setText(String.format("%02x", m_struUserCfg.struUser[m_iUserIndex].byMACAddr[3]));
        jTextFieldMac5.setText(String.format("%02x", m_struUserCfg.struUser[m_iUserIndex].byMACAddr[4]));
        jTextFieldMac6.setText(String.format("%02x", m_struUserCfg.struUser[m_iUserIndex].byMACAddr[5]));

        //本地操作权限
        jCheckBoxLocalPTZ.setSelected(m_struUserCfg.struUser[m_iUserIndex].byLocalRight[0] == 1);
	jCheckBoxLoacalRecord.setSelected(m_struUserCfg.struUser[m_iUserIndex].byLocalRight[1] == 1);
	jCheckBoxLocalPlayback.setSelected(m_struUserCfg.struUser[m_iUserIndex].byLocalRight[2] == 1);
	jCheckBoxLocalSetPara.setSelected(m_struUserCfg.struUser[m_iUserIndex].byLocalRight[3] == 1);
	jCheckBoxLocalState.setSelected(m_struUserCfg.struUser[m_iUserIndex].byLocalRight[4] == 1);
	jCheckBoxLocalUpdate.setSelected(m_struUserCfg.struUser[m_iUserIndex].byLocalRight[5] == 1);
	jCheckBoxLocalIPCamera.setSelected(m_struUserCfg.struUser[m_iUserIndex].byLocalRight[7] == 1);
	jCheckBoxLocalBackup.setSelected(m_struUserCfg.struUser[m_iUserIndex].byLocalRight[8] == 1);
	jCheckBoxLocalReboot.setSelected(m_struUserCfg.struUser[m_iUserIndex].byLocalRight[9] == 1);
        
        jComboBoxLocal.setSelectedIndex(0);
        showLocalChannel();

        //远程操作权限
	jCheckBoxRemotePTZ.setSelected(m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[0] == 1);
	jCheckBoxRemoteRecord.setSelected(m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[1] == 1);
	jCheckBoxRemotePlayback.setSelected(m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[2] == 1);
	jCheckBoxRemoteSetPara.setSelected(m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[3] == 1);
	jCheckBoxRemoteState.setSelected(m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[4] == 1);
	jCheckBoxRemoteUpdate.setSelected(m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[5] == 1);
	jCheckBoxRemoteVoice.setSelected(m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[6] == 1);
	jCheckBoxRemoteRealplay.setSelected(m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[7] == 1);
	jCheckBoxRemoteAlarm.setSelected(m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[8] == 1);
	jCheckBoxRemoteControl.setSelected(m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[9] == 1);
	jCheckBoxRemoteSerial.setSelected(m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[10] == 1);
	jCheckBoxRemoteIPCamera.setSelected(m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[12] == 1);
	jCheckBoxRemoteReboot.setSelected(m_struUserCfg.struUser[m_iUserIndex].byRemoteRight[13] == 1);

        jComboBoxRemote.setSelectedIndex(0);
        showRemoteChannel();

        //超级用户
        if(m_iUserIndex == 0)
        {
            setEnable(false);
        }
        else
        {
            setEnable(true);
        }
    }

    /*************************************************
     函数:      showLocalChannel
     函数描述:   显示本地某个权限对应的通道
      *************************************************/
    private void showLocalChannel()
    {
        int iRightType = jComboBoxLocal.getSelectedIndex();
        switch (iRightType)
        {
            case 0://本地回放
                for (int i = 0; i < HCNetSDK.MAX_CHANNUM_V30; i++)
                {
                    m_LocalChannel[i].setCheck(m_struUserCfg.struUser[m_iUserIndex].byLocalPlaybackRight[i] == 1);
                }
                break;
            case 1://本地录像
                for (int i = 0; i < HCNetSDK.MAX_CHANNUM_V30; i++)
                {
                    m_LocalChannel[i].setCheck(m_struUserCfg.struUser[m_iUserIndex].byLocalRecordRight[i] == 1);
                }
                break;
            case 2://云台控制
                for (int i = 0; i < HCNetSDK.MAX_CHANNUM_V30; i++)
                {
                    m_LocalChannel[i].setCheck(m_struUserCfg.struUser[m_iUserIndex].byLocalPTZRight[i] == 1);
                }
                break;
            case 3://本地备份
                for (int i = 0; i < HCNetSDK.MAX_CHANNUM_V30; i++)
                {
                    m_LocalChannel[i].setCheck(m_struUserCfg.struUser[m_iUserIndex].byLocalBackupRight[i] == 1);
                }
                break;
        }
        jListLocal.repaint();
    }

    /*************************************************
     函数:      showRemoteChannel
     函数描述:   显示远程某个权限对应的通道
      *************************************************/
    private void showRemoteChannel()
    {
        int iRightType = jComboBoxRemote.getSelectedIndex();
        switch (iRightType)
        {
            case 0://远程回放
                for (int i = 0; i < HCNetSDK.MAX_CHANNUM_V30; i++)
                {
                    m_RemoteChannel[i].setCheck(m_struUserCfg.struUser[m_iUserIndex].byNetPlaybackRight[i] == 1);
                }
                break;
            case 1://远程预览
                for (int i = 0; i < HCNetSDK.MAX_CHANNUM_V30; i++)
                {
                    m_RemoteChannel[i].setCheck(m_struUserCfg.struUser[m_iUserIndex].byNetPreviewRight[i] == 1);
                }
                break;
            case 2://远程手动录像
                for (int i = 0; i < HCNetSDK.MAX_CHANNUM_V30; i++)
                {
                    m_RemoteChannel[i].setCheck(m_struUserCfg.struUser[m_iUserIndex].byNetRecordRight[i] == 1);
                }
                break;
            case 3://远程云台控制
                for (int i = 0; i < HCNetSDK.MAX_CHANNUM_V30; i++)
                {
                    m_RemoteChannel[i].setCheck(m_struUserCfg.struUser[m_iUserIndex].byNetPTZRight[i] == 1);
                }
                break;
        }
        jListRemote.repaint();
    }
    /*************************************************
     函数:      setEnable
     函数描述:   设置控件可编辑性
      *************************************************/
    private void setEnable(boolean bEbnable)
    {
        jTextFieldUserName.setEnabled(bEbnable);
        jComboBoxPriority.setEnabled(bEbnable);
        jCheckBoxLocalPTZ.setEnabled(bEbnable);
	jCheckBoxLoacalRecord.setEnabled(bEbnable);
	jCheckBoxLocalPlayback.setEnabled(bEbnable);
	jCheckBoxLocalSetPara.setEnabled(bEbnable);
	jCheckBoxLocalState.setEnabled(bEbnable);
	jCheckBoxLocalUpdate.setEnabled(bEbnable);
	jCheckBoxLocalIPCamera.setEnabled(bEbnable);
	jCheckBoxLocalBackup.setEnabled(bEbnable);
	jCheckBoxLocalReboot.setEnabled(bEbnable);

	jCheckBoxRemotePTZ.setEnabled(bEbnable);
	jCheckBoxRemoteRecord.setEnabled(bEbnable);
	jCheckBoxRemotePlayback.setEnabled(bEbnable);
	jCheckBoxRemoteSetPara.setEnabled(bEbnable);
	jCheckBoxRemoteState.setEnabled(bEbnable);
	jCheckBoxRemoteUpdate.setEnabled(bEbnable);
	jCheckBoxRemoteVoice.setEnabled(bEbnable);
	jCheckBoxRemoteRealplay.setEnabled(bEbnable);
	jCheckBoxRemoteAlarm.setEnabled(bEbnable);
	jCheckBoxRemoteControl.setEnabled(bEbnable);
	jCheckBoxRemoteSerial.setEnabled(bEbnable);
	jCheckBoxRemoteIPCamera.setEnabled(bEbnable);
	jCheckBoxRemoteReboot.setEnabled(bEbnable);
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonExit;
    private javax.swing.JButton jButtonSaveLocal;
    private javax.swing.JButton jButtonSaveRemote;
    private javax.swing.JButton jButtonSaveUser;
    private javax.swing.JButton jButtonSetup;
    private javax.swing.JButton jButtonUPdate;
    private javax.swing.JCheckBox jCheckBoxLoacalRecord;
    private javax.swing.JCheckBox jCheckBoxLocalBackup;
    private javax.swing.JCheckBox jCheckBoxLocalIPCamera;
    private javax.swing.JCheckBox jCheckBoxLocalPTZ;
    private javax.swing.JCheckBox jCheckBoxLocalPlayback;
    private javax.swing.JCheckBox jCheckBoxLocalReboot;
    private javax.swing.JCheckBox jCheckBoxLocalSetPara;
    private javax.swing.JCheckBox jCheckBoxLocalState;
    private javax.swing.JCheckBox jCheckBoxLocalUpdate;
    private javax.swing.JCheckBox jCheckBoxRemoteAlarm;
    private javax.swing.JCheckBox jCheckBoxRemoteControl;
    private javax.swing.JCheckBox jCheckBoxRemoteIPCamera;
    private javax.swing.JCheckBox jCheckBoxRemotePTZ;
    private javax.swing.JCheckBox jCheckBoxRemotePlayback;
    private javax.swing.JCheckBox jCheckBoxRemoteRealplay;
    private javax.swing.JCheckBox jCheckBoxRemoteReboot;
    private javax.swing.JCheckBox jCheckBoxRemoteRecord;
    private javax.swing.JCheckBox jCheckBoxRemoteSerial;
    private javax.swing.JCheckBox jCheckBoxRemoteSetPara;
    private javax.swing.JCheckBox jCheckBoxRemoteState;
    private javax.swing.JCheckBox jCheckBoxRemoteUpdate;
    private javax.swing.JCheckBox jCheckBoxRemoteVoice;
    private javax.swing.JComboBox jComboBoxLocal;
    private javax.swing.JComboBox jComboBoxPriority;
    private javax.swing.JComboBox jComboBoxRemote;
    private javax.swing.JComboBox jComboBoxUser;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JList jListLocal;
    private javax.swing.JList jListRemote;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanelLocal;
    private javax.swing.JPanel jPanelRemote;
    private javax.swing.JPasswordField jPasswordFieldPassConfirm;
    private javax.swing.JPasswordField jPasswordFieldPassword;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JTextField jTextFieldMac1;
    private javax.swing.JTextField jTextFieldMac2;
    private javax.swing.JTextField jTextFieldMac3;
    private javax.swing.JTextField jTextFieldMac4;
    private javax.swing.JTextField jTextFieldMac5;
    private javax.swing.JTextField jTextFieldMac6;
    private javax.swing.JTextField jTextFieldUserIP;
    private javax.swing.JTextField jTextFieldUserName;
    // End of variables declaration//GEN-END:variables


     /******************************************************************************
     *类:   CheckListItemRenderer
     *JCheckBox   ListCellRenderer
     ******************************************************************************/
    public class CheckListItemRenderer extends JCheckBox implements ListCellRenderer
    {

        public Component getListCellRendererComponent(
                JList list,
                Object value,
                int index,
                boolean isSelected,
                boolean cellHasFocus)
        {
            CheckListItem item = (CheckListItem) value;
            this.setSelected(item.getCheck());
            this.setText(item.getText());
            this.setFont(list.getFont());
            this.setEnabled(list.isEnabled());
            return this;
        }
    }

    /******************************************************************************
     *类:   CheckListItem
     *
     ******************************************************************************/
    public class CheckListItem
    {

        boolean check;
        String text;

        public CheckListItem(boolean check, String text)
        {
            this.check = check;
            this.text = text;
        }

        public boolean getCheck()
        {
            return check;
        }

        public void setCheck(boolean _check)
        {
            check = _check;
        }

        public String getText()
        {
            return text;
        }

        public void setText(String _text)
        {
            text = _text;
        }
    }

    /******************************************************************************
     *类:   CheckListMouseListener
     *
     ******************************************************************************/
    class CheckListMouseListener extends MouseAdapter
    {

        public void mousePressed(MouseEvent e)
        {
            JList list = (JList) e.getSource();
            int index = list.locationToIndex(e.getPoint());
            CheckListItem item = (CheckListItem) list.getModel().getElementAt(index);
            item.setCheck(!item.getCheck());
            Rectangle rect = list.getCellBounds(index, index);
            list.repaint(rect);
        }
    }
}
